import java.util.Scanner;

/**
 * @Author: XXHH
 * @CreateTime: 2024-12-23
 */
public class Demo29 {
    public static void main(String[] args) {
        Object locker = new Object();
        Thread t1 = new Thread(()->{
            System.out.println("t1 wait之前...");
            synchronized (locker){
                try {
                    locker.wait();
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            }
            System.out.println("t1 wait之后...");
        });
        Thread t2 = new Thread(()->{
            Scanner scanner = new Scanner(System.in);
            System.out.println("随意输入,唤醒t1线程");
            scanner.next();
            synchronized (locker){
                locker.notify();
            }
        });
        t1.start();
        t2.start();
    }
}
